﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace John
{
    public partial class search : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setSelectClass();
            }

        }
       
        private void setSelectClass()//绑定 类别选框
        {
            DBConn myDB = new DBConn();
            string mySql = "select CID,CName from Category";
            ddlClass.DataSource = myDB.getDataReader(mySql);
            ddlClass.DataTextField = "CName";
            ddlClass.DataValueField = "CID";
            ddlClass.DataBind();
            myDB.Close();

            ddlClass.Items.Insert(0, new ListItem("所有分类", "-1"));
        }   
        protected void btnSelect_Click(object sender, EventArgs e)//供应
        {
            string strClass = ddlClass.SelectedValue;
            string strText = Server.UrlEncode(txtSelect.Text.Trim());

            Response.Redirect("Select.aspx?wd=1&class=" + strClass + "&text=" + strText);
        }
        protected void Button2_Click(object sender, EventArgs e)//求购
        {
            string strClass = ddlClass.SelectedValue;
            string strText = Server.UrlEncode(TextBox2.Text.Trim());

            Response.Redirect("Select.aspx?wd=2&class=" + strClass + "&text=" + strText);

        }
        protected void Button3_Click(object sender, EventArgs e)//商机
        {
            string strClass = ddlClass.SelectedValue;
            string strText = Server.UrlEncode(TextBox3.Text.Trim());

            Response.Redirect("Select.aspx?wd=3&class=" + strClass + "&text=" + strText);
        }
        protected void Button4_Click(object sender, EventArgs e)//单位
        {
            string strClass = ddlClass.SelectedValue;
            string strText = Server.UrlEncode(TextBox4.Text.Trim());

            Response.Redirect("Select.aspx?wd=4&class=" + strClass + "&text=" + strText);
        }
}
}